#if !defined(SORT_BY_EMBEDDED_NUMBERS_H)
#define SORT_BY_EMBEDDED_NUMBERS_H

#include <string>
#include <boost/regex.hpp>

namespace
{

	struct t_expand_each_number
	{
		std::string operator()(boost::smatch const& orig) const
		{
			return std::string(15 - orig.length(), '0') + orig.str();
		}
	};
	std::string zero_pad_embedded_numbers(const std::string& orig)
	{
		static boost::regex expand_num_regex("(\\d+)");
		std::string ret_str = boost::regex_replace(orig, expand_num_regex, t_expand_each_number());
		return boost::regex_replace(orig, expand_num_regex, t_expand_each_number());
	}
}

struct t_sort_by_embedded_numbers
{
	bool operator()(const std::string& a, const std::string& b) const
	{
		return zero_pad_embedded_numbers(a) < zero_pad_embedded_numbers(b);
	}
};

#endif
